
void mover_cuadrado(unsigned char* origen, unsigned char* destino, int fila_origen_size, int fila_destino_size, int tam)  {
    
    
    int indice_columna = 0;
    int indice_fila = 0;
    
    while (indice_fila < tam) {
        while (indice_columna < tam) {
				destino[indice_columna] = origen[indice_columna];
				indice_columna++;
		}
		indice_columna = 0;
		indice_fila ++;
		origen += fila_origen_size;
		destino += fila_destino_size;
		
	}
}


void recortar_c (
	unsigned char *src,
	unsigned char *dst,
	int m,
	int n,
	int src_row_size,
	int dst_row_size,
	int tam
) {
	//unsigned char (*src_matrix)[src_row_size] = (unsigned char (*)[src_row_size]) src;
	//unsigned char (*dst_matrix)[dst_row_size] = (unsigned char (*)[dst_row_size]) dst;

	// TODO: Implementar
	// de (1,1) a (m-tam, n-tam)
	unsigned char* origen = src;
	unsigned char* destino = dst;

    int indice_columna = 0;
    int indice_fila = 0;
    
    int tamx2 = tam * 2;

    while (indice_fila < tamx2) {
        while (indice_columna < tamx2) {
            /*
             *  cuadrantes:
             *  | a | b |
             *  ---------
             *  | c | d |
             *  ---------
             *
             */

            char dato;
            int fila = 0;
            int columna = 0;
            // cuadrante A
            if (indice_fila < tam && indice_columna < tam) {
                columna = n-tam + indice_columna;
                fila = m-tam + indice_fila;

            }
            // cuadrante B
            else if (indice_fila < tam && tam <= indice_columna) {
                columna = indice_columna - tam;
                fila = m-tam + indice_fila;
            
            }
            // cuadrante C
            else if (tam <= indice_fila && indice_columna < tam) {
                columna = n-tam + indice_columna;
                fila = indice_fila - tam;
            }

            // cuadrante D
            else if (tam <= indice_fila && tam <= indice_columna) {
                columna = indice_columna - tam;
                fila = indice_fila - tam;
            }

            dato = origen[fila * src_row_size + columna];
            destino[indice_columna + indice_fila * dst_row_size] = dato;

            indice_columna++;
        }
        indice_columna = 0;
        indice_fila++;
    }
}
